home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tclX6.4c / dist / tests / convlib.test < prev    next >
Encoding:
Text File  |  1992-11-07  |  2.3 KB  |  74 lines

  1. #
  2. # convlib.test
  3. #
  4. # Tests for tcl.tlib convert_lib routine.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: convlib.test,v 2.0 1992/10/16 04:49:34 markd Rel $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] == ""} then {source testlib.tcl}
  20. rename SAVED_UNKNOWN unknown
  21.  
  22. # Create a temporary tclIndex file and the files it points to.
  23.  
  24. set fh [open tclIndex w]
  25. loop num 0 5 {
  26.     puts $fh "LoadProc${num}A tmp${num}.tcl"
  27.     puts $fh "LoadProc${num}B tmp${num}.tcl"
  28. }
  29. puts $fh "foo init.tcl"  ;# Should not be used.
  30. close $fh
  31.  
  32. loop num 0 5 {
  33.     set fh [open tmp${num}.tcl w]
  34.     puts $fh "proc LoadProc${num}A {} {return @LoadProc${num}A@}"
  35.     puts $fh "proc LoadProc${num}B {} {return @LoadProc${num}B@}"
  36.     close $fh
  37. }
  38.  
  39. # Proc that validates the library by executing procs out of it.
  40.  
  41. proc LibValidate {testid testname} {
  42.     loop num 0 5 {
  43.         test $testid $testname {
  44.             LoadProc${num}A
  45.         } "@LoadProc${num}A@"
  46.         test $testid $testname {
  47.             LoadProc${num}B
  48.         } "@LoadProc${num}B@"
  49.     }
  50. }
  51.  
  52. #
  53. # Now convert and load the library, see if we can actually use it.
  54. #
  55.  
  56. test convlib-1.1 {Convert library tests} {
  57.     unlink -nocomplain {tmp.tlib tmp.tndx}
  58.     convert_lib [pwd]/tclIndex tmp  "init.tcl"
  59.     list [file exists tmp.tlib] [file exists tmp.tndx]
  60. } {1 1}
  61.  
  62. test convlib-1.2 {Convert library tests} {
  63.     unlink -nocomplain {tmp.tlib tmp.tndx}
  64.     convert_lib [pwd]/tclIndex tmp.tlib "init.tcl"
  65.     loadlibindex tmp.tlib
  66.     list [file exists tmp.tlib] [file exists tmp.tndx]
  67. } {1 1}
  68.  
  69. LibValidate convlib-1.3 {Convert library tests}
  70.  
  71. unlink -nocomplain {tmp0.tcl tmp1.tcl tmp2.tcl tmp3.tcl tmp4.tcl
  72.                     tmp.tlib tmp.tndx tclIndex}
  73. rename unknown SAVED_UNKNOWN
  74.